package upicgame.article.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import upicgame.article.dao.ArticleDao;
import upicgame.entity.Article;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: upicgame
 * @description: 文章实现类
 * @author: lhq
 * @create: 2020-01-03 10:21
 */
@Service(value = "articleService")
@Transactional(propagation = Propagation.REQUIRES_NEW,isolation = Isolation.DEFAULT,rollbackFor = Exception.class)
public class ArticleService {
	@Resource
	private ArticleDao articleDao;

	public Long getCount(){
		return articleDao.totalCount();
	}
	public Article selectArticle(Integer id){
		return  articleDao.findArticle(id);
	}
	public boolean updateArticle(Article article){
		return articleDao.updateArticle(article);
	}
	public boolean delArticle(Integer id){
		Article article = articleDao.findArticle(id);
		return articleDao.delArticle(article);
	}
	public boolean addArticle(Article article){
		return articleDao.addArticle(article);
	}
	public List<Article> articleList(Integer currentPage, Integer size){
		return articleDao.findAllArticleByPage(currentPage,size);
	}
	public List<String> getTitle(){
		return articleDao.getTitle();
	}
}
